<?php
class Event {
		var $EventID;
		var $CalendarID;
		var $DiscussionID;
		var $UserID;
		var $RecurID;
		var $Name;
		var $Description;
		var $Approved;
		var $StartDate;
		var $EndDate;
		var $StartTime;
		var $EndTime;
		var $AllDayEvent;
		var $DateCreated;
		var $Title;
		var $RequireApproval;
		var $ColorArr;
		var $ColorStr;
		var $Blocked;
		var $Context;

		// Constructor
		function Event(&$Context) {
			$this->Context = &$Context;
			$this->Clear();
		}

		function Clear() {
			$this->EventID = 0;
			$this->CalendarID = 0;
			$this->DiscussionID = 0;
			$this->UserID = 0;
			$this->RecurID = 0;
			$this->Name = "";
			$this->Description = "";
			$this->Approved = 1;
			$this->StartDate = "";
			$this->EndDate = "";
			$this->StartTime = "";
			$this->EndTime = "";
			$this->DateCreated = "";
			$this->Title = "";
			$this->RequireApproval = 0;
			$this->ColorArr = array();
			$this->ColorStr = '';
			$this->Blocked = 0;
			$this->CustomFieldsStr = '';
			$this->CustomFieldsArr = array();
		}

		function GetPropertiesFromDataSet(&$Configuration,$DataSet) {
			$this->EventID = @$DataSet['EventID'];
			$this->CalendarID = @$DataSet['CalendarID'];
			$this->DiscussionID = @$DataSet['DiscussionID'];
			$this->UserID = @$DataSet['UserID'];
			$this->RecurID = @$DataSet['RecurID'];
			$this->Name = @$DataSet['Name'];
			$this->Description = @$DataSet['Description'];
			$this->Approved = @$DataSet['Approved'];
			$this->StartDate = @$DataSet['StartDate'];
			$this->EndDate = @$DataSet['EndDate'];
			$this->StartTime = @$DataSet['StartTime'];
			$this->EndTime = @$DataSet['EndTime'];
			$this->RequireApproval = @$DataSet['RequireApproval'];
			$this->DateCreated = @$DataSet['DateCreated'];
			$this->Title = @$DataSet['Title'];
			$this->AllDayEvent = @$DataSet['AllDayEvent'];
			$this->ColorStr = @$DataSet['Color'];
			$this->Blocked = @$DataSet['Blocked'];
		}
		function FormatPropertiesForDisplay() {
			$this->Name = FormatStringForDisplay($this->Name);
			$this->Description = FormatStringForDisplay($this->Description);
			$this->Title = FormatStringForDisplay($this->Title);
			$this->StartDate = FormatStringForDisplay($this->StartDate);
			$this->EndDate = FormatStringForDisplay($this->EndDate);
			$this->StartTime = FormatStringForDisplay($this->StartTime);
			$this->EndTime = FormatStringForDisplay($this->EndTime);
			$this->ColorArr = UnserializeAssociativeArray($this->ColorStr);
		}
		function GetPropertiesFromForm(&$Discussion) {
			$this->EventID = ForceIncomingInt('EventID', 0);
			$this->CalendarID = ForceIncomingInt('CalendarID', 0);
			$this->UserID = $this->Context->Session->UserID;
			$this->DiscussionID = $Discussion->DiscussionID;
			$this->Name = $Discussion->Name;
			$this->StartDate = ForceIncomingString('StartDate', '');
			$this->EndDate = ForceIncomingString('EndDate', '');
			$this->StartTime = ForceIncomingString('StartTime', '');
			$this->EndTime = ForceIncomingString('EndTime', '');
			$this->AllDayEvent = ForceIncomingInt('AllDayEvent', 0);
			$this->DateCreated = MySqlDateTime();
		}
		function FormatPropertiesForDatabaseInput() {
			$this->Name = FormatStringForDatabaseInput($this->Name,1);
			$this->StartDate = strftime("%Y-%m-%d",strtotime($this->StartDate));
			$this->EndDate = strftime("%Y-%m-%d",strtotime($this->EndDate));
			$this->StartTime = strftime("%T",strtotime($this->StartTime));
			$this->EndTime = strftime("%T",strtotime($this->EndTime));
		}
	}
?>
